<template>
    <j-modal
      width="1000px"
      title="房间信息"
      :maskClosable="false"
      :destroyOnClose="true"
      :visible.sync="editModalVisible"
      @cancel="handleCancleDbSync"
    >
      <template slot="footer">
        <a-button @click="handleCancleDbSync">取消</a-button>
        <a-button type="primary" :loading="syncLoading" @click="handleDbSync">确定</a-button>
      </template>
      <a-form-model layout="inline" @keyup.enter.native="searchQuery">
        <a-form-model-item label="房源号">
          <a-input v-model="queryParam.houseCode" placeholder="请选择房源号"/>
        </a-form-model-item>
        <a-form-model-item label="房源类型">
          <j-dict-select-tag
            style="width:180px;"
            v-model="queryParam.houseType"
            placeholder="请选择房源类型"
            dict-code="park_housing_types"
          >
          </j-dict-select-tag>
        </a-form-model-item>
        <a-form-model-item>
          <a-button type="primary" icon="search" @click="searchQuery">查询</a-button>
          <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
        </a-form-model-item>
      </a-form-model>
      <vxe-grid
        ref="xTable"
        border
        resizable
        keep-source
        max-height="400px"
        align="center"
        :columns="columns"
        :data="dataSource"
        @checkbox-all="onSelectChange"
        @checkbox-change="onSelectChange"
      >
        <template v-slot:pager>
          <vxe-pager
            :layouts="layouts"
            :current-page.sync="ipagination.currentPage"
            :page-size.sync="ipagination.pageSize"
            :total="ipagination.total"
            @page-change="handlePageChange"
          >
          </vxe-pager>
        </template>
      </vxe-grid>
  </j-modal>
</template>
<script>
import { VxeTableMixin } from '@/mixins/VxeTableMixin'
import { filterObj } from '@/utils/util'
export default {
  name: 'HomeListModal',
  mixins: [VxeTableMixin],
  data() {
    return {
      editModalVisible: false,
      disableSubmit: false,
      syncLoading: false,
      url: {
        list: '/community/xyParkHouse/list'
      },
      columns: [
        { type: 'checkbox', width: 50 },
        { type: 'seq', width: 60 },
        { field: 'houseCode', title: '房源号' },
        { field: 'projectName', title: '所属项目' },
        { field: 'buildingName', title: '所属楼宇' },
        { field: 'floor', title: '所属楼层' },
        { field: 'buildingArea', title: '建筑面积' },
        { field: 'propertyArea', title: '产权面积' },
        { field: 'houseType_dictText', title: '房源类型' }
      ],
      queryParam: {
        houseStatus: '1,5'
      }
    }
  },
  methods: {
    show() {
      this.editModalVisible = true
    },
    handleCancleDbSync() {
      this.editModalVisible = false
    },
    handleDbSync() {
      if (this.selectionRows.length) {
        this.editModalVisible = false
        this.$emit('ok', this.selectionRows)
      } else {
        this.$message.warning('请选择房源')
      }
    },
    searchReset() {
      this.queryParam = { houseStatus: '1,5' }
      this.loadData()
    },
    getQueryParams() {
      // 获取查询条件
      const sqp = {}
      if (this.superQueryParams) {
        sqp['superQueryParams'] = encodeURI(this.superQueryParams)
        sqp['superQueryMatchType'] = this.superQueryMatchType
      }
      const queryParam = { ...this.queryParam }
      queryParam.houseCode = queryParam.houseCode ? '*' + queryParam.houseCode + '*' : undefined
      var param = Object.assign(sqp, queryParam, this.isorter, this.filters)
      param.field = this.getQueryField()
      param.pageNo = this.ipagination.currentPage
      param.pageSize = this.ipagination.pageSize
      return filterObj(param)
    }
  }
}
</script>
<style lang="less">

</style>
